#用于重新修正指定商品的库存
#
#


=begin
例如:销售出库单WSMPT20181227-1125在实际已出库，但未发货，而库存已经盘过的情况下提交了发货
select id into @wsb_id from psi.t_ws_bill where ref='WSMPT20181227-1125' and bill_status=1000;
select * from psi.t_ws_bill_detail where wsbill_id=@wsb_id;
select * from psi.t_inventory where goods_id in (select goods_id from psi.t_ws_bill_detail where wsbill_id=@wsb_id);
select * from psi.t_inventory_detail where goods_id in (select goods_id from psi.t_ws_bill_detail where wsbill_id=@wsb_id) and ( ref_number='WSMPT20181227-1125' or ref_number='IC20181227001' );

对应的三个商品是，数量分别似乎-2,-2,-3
A74D994D-FEB1-11E8-8932-6C92BF475963
E9A8D1F7-01DE-11E9-8932-6C92BF475963
51E293C1-FC53-11E8-8932-6C92BF475963

1) 手工重置入库单计算的入库数量，增加对应的数量(用程序则严格从对应bill的goodid开始，更新指定入库单产生的入库数)
2）用本程序重新计算库存数
=end

#
#
load 'util_fix_goods.rb'

targetGoodsID=[ 
        '76BD46BC-E611-11E8-8B92-6C92BF475963',
        '741169A7-E611-11E8-8B92-6C92BF475963'
]

targetGoodsID.each do |gid|
    rebuild_inventory_by_goods_id(gid)
end
